﻿using System;
using System.Windows.Forms;
using Library.Interface;

namespace NameplateReport
{
    public partial class ModifyNamePlate : UserControl
    {
        public bool isEdit { get; set; }
        public IBaseObject NamePlate { get; set; }
        public INamePlateManager INamePlateManager { get; set; }
        public ModifyNamePlate()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            if (INamePlateManager != null)
            {
                INamePlateManager.Cancel(this);
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (NamePlate == null) return;
            if (isEdit)
                NamePlate.Update();
            else NamePlate.Insert();
        }

        private void ModifyNamePlate_Load(object sender, EventArgs e)
        {
            if (NamePlate == null) return;
            txtCode.Text = string.Empty + NamePlate[NamePlateField.Code];
            txtName.Text = string.Empty + NamePlate[NamePlateField.FriendlyName];
        }
    }
}
